﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CutDown : MonoBehaviour {

    public UISprite clockSprite;
    public float passTime;
    public UILabel timeLabel;
    private int num;
    private float initTime;
    void Start()
    {
        initTime = passTime;
        StartCoroutine(ChangeSprite());
    }

    void Update()
    {
        passTime = passTime - Time.deltaTime;
        int i = (int)passTime;
        timeLabel.text = i.ToString();
        if (passTime <= 0)
        {
            //StartCoroutine(DealCards());  
            Destroy(gameObject);
        }
    }

    IEnumerator ChangeSprite()
    {
        while(passTime > 0){
            if(num < 10){
                clockSprite.spriteName = "jiazai_0000" + num.ToString();
            }
            else
            {
                clockSprite.spriteName = "jiazai_000" + num.ToString();
            }
            yield return new WaitForSeconds(initTime / 30);
            num++;
        }
        
    }
}
